package com.itheima.sh;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
//@EnableEurekaClient  //Eureka客户端
@EnableDiscoveryClient
//@EnableFeignClients(basePackages ="com.itheima.sh.clients" ) // 开启Feign功能
@EnableCircuitBreaker //Hystrix 熔断器的开启注解
//@SpringCloudApplication//这一个注解相当于上面三个
public class ConsumerApplication {

    public static void main(String[] args) {
        SpringApplication.run(ConsumerApplication.class, args);
        System.out.println("consume启动了");

    }

    // 注册RestTemplate的对象到Spring的容器中
    @Bean
    @LoadBalanced  //开启负载均衡的功能
    public RestTemplate restTemplate() {

        return new RestTemplate();

    }

/*
    //第二种：配置负载均衡的策略的方法  为随机,ribbon默认的是轮询
    @Bean
    public IRule rule() {
        return new RandomRule();
    }
*/


}
